<?php

namespace app\admin\controller;

use app\admin\BaseController;

class ActivityEnlistController extends BaseController
{
    /**
     * 获取商品列表
     * @return \think\response\Json
     */
    public function listsAction()
    {
        try{
            $post = $this->get;

            $params['order'] = ['signId'=>'desc'];

            if(!empty($post['activityId'])){
                $params['where'][] = ['activityId', '=', $post['activityId']];
            }

            $res = $this->app->activityEnlistService->getLists($params, $this->page, $this->pagesize);

            $data['lists'] = [];
            foreach($res as $key=>$vo){
                $data['lists'][] = [
                    'signId' => $vo->signId,
                    'activityId' => $vo->activityId,
                    'activityName' => $vo->activity->activityName,
                    'userId' => $vo->user->userId,
                    'userName' => $vo->user->userName,
                    'realName' => $vo->user->realName,
                    'phone' => $vo->user->phone,
                    'universityName' => $vo->user->universityId?$vo->user->university->universityName:'',
                    'createdAt' => $vo->createdAt
                ];
            }

            $data['totalInfo'] = $this->app->utilService->getMeta($res);

            return json(['code' => 200, 'msg' => '查询成功', 'data'=> $data]);
        }catch(\Exception $e){
            return json(['code' => $e->getCode(), 'msg' => $e->getMessage(), 'data'=> []]);
        }
    }
}